package com.test.controller;

import com.test.config.WebsocketClient;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * @author chenming
 * @description
 * @create: 2022-07-26
 */
@RestController
@RequestMapping("/test")
public class WebsocketTestController {

    @GetMapping("/get")
    public void test(Integer num) {
        try {
            for (Integer i = 0; i < num; i++) {
                WebsocketClient websocketClient = new WebsocketClient(new URI("ws://127.0.0.1:8081/websocket/" + i));
                websocketClient.connect();
            }
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

}
